﻿Public Class FrmReport
    Dim y As Integer

    Sub New()
        InitializeComponent()
        y = ClientRectangle.Right - Button2.Right
        ListView1.View = View.List
        ListView1.SmallImageList = New ImageList
        ListView1.SmallImageList.ColorDepth = ColorDepth.Depth32Bit
        ListView1.SmallImageList.ImageSize = New Size(20, 20)
        ListView1.SmallImageList.Images.Add(My.Resources.chart.Resize(20, 20, 2))
        ListView1.Items.Add("Aya göre izinli personel", 0)
        ListView1.HideSelection = False
        ListView1.Items(0).Selected = True
        InfoBox.ShowMessage("i", "Rapor türünü seçin ve rapor parametrelerini girin.")
    End Sub

    Function AddCombo(Name As String, Text As String, Source As List(Of SourceItem)) As ComboBox
        Dim Combo As New ComboBox
        Combo.Name = Name
        Panel1.Controls.Add(Combo)
        Combo.LoadItems(Source)
        Combo.Anchor = Combo.Anchor Or AnchorStyles.Right
        Combo.Location = New Point(80, y)
        Combo.Width = Panel1.Width - Combo.Left
        Combo.DropDownStyle = ComboBoxStyle.DropDownList
        'Height += Combo.Height + 4
        Dim Label As New Label
        Panel1.Controls.Add(Label)
        Label.AutoSize = True
        Label.Text = Text & " :"
        Label.Location = New Point(Combo.Left - Label.Width - 4, y + 3)
        y += 6 + Combo.Height
        Return Combo
    End Function

    Private Sub ListView1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListView1.SelectedIndexChanged
        Static Last As Integer = -1
        If ListView1.SelectedItems.Count < 1 Then Return
        If ListView1.SelectedItems(0).Index = Last Then Exit Sub
        Last = ListView1.SelectedItems(0).Index
        Panel1.Controls.Clear()
        y = 0
        Select Case Last
            Case 0
                'Text = "Aya Göre İzinli Personel Raporu"
                Dim birim = AddCombo("birim", "Bölüm", Kullanici.Birimler)
                Dim ay = AddCombo("ay", "Yıl/ay", Service.Combo.Aylar)
                If Kullanici.TBirim <> 0 Then birim.SetValue(Kullanici.TBirim) : birim.Enabled = False
        End Select
    End Sub

End Class